/**
 * Created by xiangyufang on 2016/9/7.
 */
;(function($,window,document,undefined){
    /*** 全局变量 start ***/
    var $power_table = $('#JQ_datatable_power');
    var $long_table = $('#JQ_datatable_long');
    var $bed_table = $('#JQ_datatable_bed');
    var $insu_table = $('#JQ_datatable_insu');
    var $avoid_table = $('#JQ_datatable_avoid');
    var $line_table = $('#JQ_datatable_line');
    var $cpile_table = $('#JQ_datatable_pile');
    var $sacri_table = $('#JQ_datatable_sacri');
    var $elec_table = $('#JQ_datatable_elec');
    var DTPOWER,DTLONG,DTBED,DTINSU,DTAVOID,DTLINE,DTPILE,DTSACRI,DTELEC;

    var $nav = $('.xyf-tab-nav>li');
    var $nav_content = $('div.xyf-nav-content');

    function PSBES(Pile,Segment,Begin,End,Station){
        // 触发管道
        Pile.element.on('select',function(e,v){
            var id = v || Pile.val();
            if(id){
                // 管段
                DyyBase.ajax(DyyBase.url_segment(), {pipeLineId:id}, function(dataset){
                    var json = DyyBase.getSelect(dataset);
                    Segment.add(json);
                });
                // 起点 & 终点
                DyyBase.ajax(DyyBase.url_pipe_pos(), {pipeLineId:id}, function(dataset){
                    var begin = DyyBase.getPos(dataset,'begin');
                    var end = DyyBase.getPos(dataset,'end');
                    Begin.asset(begin);
                    End.asset(end);
                });
                // 所属场站阀室
                DyyBase.ajax(DyyBase.url_sign(), {pipeLineId:id,targetType:'valveRoomStation'}, function(dataset){
                    var json = DyyBase.getSelect(dataset);
                    Station.add(json);
                });
            }else{
                Segment.add([]);
                Begin.add([]);
                End.add([]);
                Station.add([]);
            }
        });
        // 触发管段
        Segment.element.on('select',function(e,v){
            var pipeId = Pile.val();
            var id = v || Segment.val();
            if(id){
                // 起点 & 终点
                DyyBase.ajax(DyyBase.url_segment_pos(), {pipeSegmentId:id}, function(dataset){
                    var begin = DyyBase.getPos(dataset,'begin');
                    var end = DyyBase.getPos(dataset,'end');
                    Begin.asset(begin);
                    End.asset(end);
                });
                // 所属场站阀室
                DyyBase.ajax(DyyBase.url_sign(), {pipeLineId:pipeId,pipeSegmentId:id,targetType:'valveRoomStation'}, function(dataset){
                    var json = DyyBase.getSelect(dataset);
                    Station.add(json);
                });
            }else{
                Begin.add([]);
                End.add([]);
                Station.add([]);
            }
        });
        //触发起点
        Begin.element.on('select',function(e,v){
            var pipeId = Pile.val();
            var id = v ||Begin.val();
            if(id){
                // 所属场站阀室
                DyyBase.ajax(DyyBase.url_sign(), {pipeLineId:pipeId,beginSignId:id,targetType:'valveRoomStation'}, function(dataset){
                    var json = DyyBase.getSelect(dataset);
                    Station.add(json);
                });
            }else{
                Station.add([]);
            }
        });
        //触发终点
        End.element.on('select',function(e,v){
            var pipeId = Pile.val();
            var id =v || End.val();
            if(id){
                // 所属场站阀室
                DyyBase.ajax(DyyBase.url_sign(), {pipeLineId:pipeId,endSignId:id,targetType:'valveRoomStation'}, function(dataset){
                    var json = DyyBase.getSelect(dataset);
                    Station.add(json);
                });
            }else{
                Station.add([]);
            }
        });
    }
    /*** 全局变量 end ***/

    /***阴保电源表单start***/
    //阴保电源类型
    var $power_type = $('#JQ_power_type').select3();
    //保护对象
    var $power_protect = $('#JQ_power_protect').select3();
    DyyBase.ajax(corrctrlApi.url_power_protect(), {}, function(dataset){
        var json = DyyBase.getSelect(dataset);
        $power_protect.add(json);
        $bed_protect.add(json);  //此为阳极地床的保护对象，数据与阴保电源的数据为同一个链接，所以可直接添加
    });
    // 管道
    var $power_pipeline = $('#JQ_pipeline').select3();
    // 管段
    var $power_segment = $('#JQ_power_segment').select3({
        title:'管段'
    });
    // 起点位置
    var $power_begin = $('#JQ_power_begin').select3({
        title: '起点位置',
        server: true,
        param: {'pipeLineId':$power_pipeline,'pipeSegmentId':$power_segment}
    });
    // 终点位置
    var $power_end = $('#JQ_power_end').select3({
        title:'终点位置',
        server: true,
        param: {'pipeLineId':$power_pipeline,'pipeSegmentId':$power_segment,'beginSignId':$power_begin}
    });
    //所属场站阀室
    var $power_station = $('#JQ_power_station').select3({
        title:'终点位置',
        server: true,
        param: {'pipeLineId':$power_pipeline,'pipeSegmentId':$power_segment,'beginSignId':$power_begin,endSignId:$power_end,targetType:'valveRoomStation'}
    });
    PSBES($power_pipeline,$power_segment,$power_begin,$power_end,$power_station);
    /***阴保电源表单end***/

    /***长效参比表单start***/
    //长效参比类型
    var $long_type = $('#JQ_long_type').select3();
    // 管道
    var $long_pipeline = $('#JQ_long_pipeline').select3({
        data: $power_pipeline.val('store'),
        title: '管道'
    });
    // 管段
    var $long_segment = $('#JQ_long_segment').select3({
        title:'管段'
    });
    // 起点位置
    var $long_begin = $('#JQ_long_begin').select3({
        title: '起点位置',
        server: true,
        param: {'pipeLineId':$long_pipeline,'pipeSegmentId':$long_segment}
    });
    // 终点位置
    var $long_end = $('#JQ_long_end').select3({
        title:'终点位置',
        server: true,
        param: {'pipeLineId':$long_pipeline,'pipeSegmentId':$long_segment,'beginSignId':$long_begin}
    });
    //所属场站阀室
    var $long_station = $('#JQ_long_station').select3({
        title:'所属场站阀室',
        server: true,
        param: {'pipeLineId':$long_pipeline,'pipeSegmentId':$long_segment,'beginSignId':$long_begin,'endSignId':$long_end,'targetType':'valveRoomStation'}
    });
    PSBES($long_pipeline,$long_segment,$long_begin,$long_end,$long_station);
    /***长效参比表单end***/

    /***阳极地床表单start***/
    //阳极材料类型
    var $bed_type = $('#JQ_bed_type').select3();
    //保护对象
    var $bed_protect = $('#JQ_bed_protect').select3();
    // 管道
    var $bed_pipeline = $('#JQ_bed_pipeline').select3({
        data: $power_pipeline.val('store'),
        title: '管道'
    });
    // 管段
    var $bed_segment = $('#JQ_bed_segment').select3({
        title:'管段'
    });
    // 起点位置
    var $bed_begin = $('#JQ_bed_begin').select3({
        title: '起点位置',
        server: true,
        param: {'pipeLineId':$long_pipeline,'pipeSegmentId':$long_segment}
    });
    // 终点位置
    var $bed_end = $('#JQ_bed_end').select3({
        title:'终点位置',
        server: true,
        param: {'pipeLineId':$bed_pipeline,'pipeSegmentId':$bed_segment,'beginSignId':$bed_begin}
    });
    //所属场站阀室
    var $bed_station = $('#JQ_bed_station').select3({
        title:'所属场站阀室',
        server: true,
        param: {'pipeLineId':$bed_pipeline,'pipeSegmentId':$bed_segment,'beginSignId':$bed_begin,'endSignId':$bed_end,'targetType':'valveRoomStation'}
    });
    PSBES($bed_pipeline,$bed_segment,$bed_begin,$bed_end,$bed_station);
    /***阳极地床表单end***/

    /***绝缘装置表单start***/
    // 管道
    var $insu_pipeline = $('#JQ_insu_pipeline').select3({
        data: $power_pipeline.val('store'),
        title: '管道'   //val('text')('mile')('store')
    });
    // 管段
    var $insu_segment = $('#JQ_insu_segment').select3({
        title:'管段'
    });
    // 起点位置
    var $insu_begin = $('#JQ_insu_begin').select3({
        title: '起点位置',
        server: true,
        param: {'pipeLineId':$insu_pipeline,'pipeSegmentId':$insu_segment}
    });
    // 终点位置
    var $insu_end = $('#JQ_insu_end').select3({
        title:'终点位置',
        server: true,
        param: {'pipeLineId':$insu_pipeline,'pipeSegmentId':$insu_segment,'beginSignId':$insu_begin}
    });
    //所属场站阀室
    var $insu_station = $('#JQ_insu_station').select3({
        title:'所属场站阀室',
        server: true,
        param: {'pipeLineId':$insu_pipeline,'pipeSegmentId':$insu_segment,'beginSignId':$insu_begin,'endSignId':$insu_end,'targetType':'valveRoomStation'}
    });
    PSBES($insu_pipeline,$insu_segment,$insu_begin,$insu_end,$insu_station);
    /***绝缘装置表单end***/

    /***防浪涌保护器表单start***/
    // 管道
    var $avoid_pipeline = $('#JQ_avoid_pipeline').select3({
        data: $power_pipeline.val('store'),
        title: '管道'
    });
    // 管段
    var $avoid_segment = $('#JQ_avoid_segment').select3({
        title:'管段'
    });
    // 起点位置
    var $avoid_begin = $('#JQ_avoid_begin').select3({
        title: '起点位置',
        server: true,
        param: {'pipeLineId':$avoid_pipeline,'pipeSegmentId':$avoid_segment}
    });
    // 终点位置
    var $avoid_end = $('#JQ_avoid_end').select3({
        title:'终点位置',
        server: true,
        param: {'pipeLineId':$avoid_pipeline,'pipeSegmentId':$avoid_segment,'beginSignId':$avoid_begin}
    });
    //所属场站阀室
    var $avoid_station = $('#JQ_avoid_station').select3({
        title:'所属场站阀室',
        server: true,
        param: {'pipeLineId':$avoid_pipeline,'pipeSegmentId':$avoid_segment,'beginSignId':$avoid_begin,'endSignId':$avoid_end,'targetType':'valveRoomStation'}
    });
    PSBES($avoid_pipeline,$avoid_segment,$avoid_begin,$avoid_end,$avoid_station);
    /***防浪涌保护器表单end***/

    /***跨接线表单start***/
    // 管道
    var $line_pipeline = $('#JQ_line_pipeline').select3({
        data: $power_pipeline.val('store'),
        title: '管道'
    });
    // 管段
    var $line_segment = $('#JQ_line_segment').select3({
        title:'管段'
    });
    // 起点位置
    var $line_begin = $('#JQ_line_begin').select3({
        title: '起点位置',
        server: true,
        param: {'pipeLineId':$line_pipeline,'pipeSegmentId':$line_segment}
    });
    // 终点位置
    var $line_end = $('#JQ_line_end').select3({
        title:'终点位置',
        server: true,
        param: {'pipeLineId':$line_pipeline,'pipeSegmentId':$line_segment,'beginSignId':$line_begin}
    });
    //所属场站阀室
    var $line_station = $('#JQ_line_station').select3({
        title:'所属场站阀室',
        server: true,
        param: {'pipeLineId':$line_pipeline,'pipeSegmentId':$line_segment,'beginSignId':$line_begin,'endSignId':$line_end,'targetType':'valveRoomStation'}
    });
    PSBES($line_pipeline,$line_segment,$line_begin,$line_end,$line_station);
    /***跨接线表单end***/

    /***测试阴保桩表单start***/
    //功能
    var $pile_function = $('#JQ_pile_function').select3();
    // 管道
    var $pile_pipeline = $('#JQ_pile_pipeline').select3({
        data: $power_pipeline.val('store'),
        title: '管道'
    });
    // 管段
    var $pile_segment = $('#JQ_pile_segment').select3({
        title:'管段'
    });
    // 起点位置
    var $pile_begin = $('#JQ_pile_begin').select3({
        title: '起点位置',
        server: true,
        param: {'pipeLineId':$pile_pipeline,'pipeSegmentId':$pile_segment}
    });
    // 终点位置
    var $pile_end = $('#JQ_pile_end').select3({
        title:'终点位置',
        server: true,
        param: {'pipeLineId':$pile_pipeline,'pipeSegmentId':$pile_segment,'beginSignId':$pile_begin}
    });
    // 触发管道
    $pile_pipeline.element.on('select',function(e,v){
        var id = v || $pile_pipeline.val();
        if(id){
            // 管段
            DyyBase.ajax(DyyBase.url_segment(), {pipeLineId:id}, function(dataset){
                var json = DyyBase.getSelect(dataset);
                $pile_segment.add(json);
            });
            // 起点 & 终点
            DyyBase.ajax(DyyBase.url_pipe_pos(), {pipeLineId:id}, function(dataset){
                var begin = DyyBase.getPos(dataset,'begin');
                var end = DyyBase.getPos(dataset,'end');
                $pile_begin.asset(begin);
                $pile_end.asset(end);
            });
        }else{
            $pile_segment.add([]);
            $pile_begin.add([]);
            $pile_end.add([]);
        }
    });
    // 触发管段
    $pile_segment.element.on('select',function(e,v){
        var id = v || $pile_segment.val();
        if(id){
            // 起点 & 终点
            DyyBase.ajax(DyyBase.url_segment_pos(), {pipeSegmentId:id}, function(dataset){
                var begin = DyyBase.getPos(dataset,'begin');
                var end = DyyBase.getPos(dataset,'end');
                $pile_begin.asset(begin);
                $pile_end.asset(end);
            });
        }else{
            $pile_begin.add([]);
            $pile_end.add([]);
        }
    });
    /***测试阴保桩表单end***/

    /***牺牲阳极表单start***/
    //保护对象
    var $sacri_protect = $('#JQ_sacri_protect').select3();
    // 管道
    var $sacri_pipeline = $('#JQ_sacri_pipeline').select3({
        data: $power_pipeline.val('store'),
        title: '管道'
    });
    // 管段
    var $sacri_segment = $('#JQ_sacri_segment').select3({
        title:'管段'
    });
    // 起点位置
    var $sacri_begin = $('#JQ_sacri_begin').select3({
        title: '起点位置',
        server: true,
        param: {'pipeLineId':$sacri_pipeline,'pipeSegmentId':$sacri_segment}
    });
    // 终点位置
    var $sacri_end = $('#JQ_sacri_end').select3({
        title:'终点位置',
        server: true,
        param: {'pipeLineId':$sacri_pipeline,'pipeSegmentId':$sacri_segment,'beginSignId':$sacri_begin}
    });
    // 触发管道
    $sacri_pipeline.element.on('select',function(e,v){
        var id = v || $sacri_pipeline.val();
        if(id){
            // 管段
            DyyBase.ajax(DyyBase.url_segment(), {pipeLineId:id}, function(dataset){
                var json = DyyBase.getSelect(dataset);
                $sacri_segment.add(json);
            });
            // 起点 & 终点
            DyyBase.ajax(DyyBase.url_pipe_pos(), {pipeLineId:id}, function(dataset){
                var begin = DyyBase.getPos(dataset,'begin');
                var end = DyyBase.getPos(dataset,'end');
                $sacri_begin.asset(begin);
                $sacri_end.asset(end);
            });
        }else{
            $sacri_segment.add([]);
            $sacri_begin.add([]);
            $sacri_end.add([]);
        }
    });
    // 触发管段
    $sacri_segment.element.on('select',function(e,v){
        var id = v || $sacri_segment.val();
        if(id){
            // 起点 & 终点
            DyyBase.ajax(DyyBase.url_segment_pos(), {pipeSegmentId:id}, function(dataset){
                var begin = DyyBase.getPos(dataset,'begin');
                var end = DyyBase.getPos(dataset,'end');
                $sacri_begin.asset(begin);
                $sacri_end.asset(end);
            });
        }else{
            $sacri_begin.add([]);
            $sacri_end.add([]);
        }
    });
    /***牺牲阳极表单end***/

    /***排流装置表单start***/
    //排流器类型
    var $elec_type = $('#JQ_elec_type').select3();
    // 管道
    var $elec_pipeline = $('#JQ_elec_pipeline').select3({
        data: $power_pipeline.val('store'),
        title: '管道'
    });
    // 管段
    var $elec_segment = $('#JQ_elec_segment').select3({
        title:'管段'
    });
    // 起点位置
    var $elec_begin = $('#JQ_elec_begin').select3({
        title: '起点位置',
        server: true,
        param: {'pipeLineId':$elec_pipeline,'pipeSegmentId':$elec_segment}
    });
    // 终点位置
    var $elec_end = $('#JQ_elec_end').select3({
        title:'终点位置',
        server: true,
        param: {'pipeLineId':$elec_pipeline,'pipeSegmentId':$elec_segment,'beginSignId':$elec_begin}
    });
    // 触发管道
    $elec_pipeline.element.on('select',function(e,v){
        var id = v || $elec_pipeline.val();
        if(id){
            // 管段
            DyyBase.ajax(DyyBase.url_segment(), {pipeLineId:id}, function(dataset){
                var json = DyyBase.getSelect(dataset);
                $elec_segment.add(json);
            });
            // 起点 & 终点
            DyyBase.ajax(DyyBase.url_pipe_pos(), {pipeLineId:id}, function(dataset){
                var begin = DyyBase.getPos(dataset,'begin');
                var end = DyyBase.getPos(dataset,'end');
                $elec_begin.asset(begin);
                $elec_end.asset(end);
            });
        }else{
            $elec_segment.add([]);
            $elec_begin.add([]);
            $elec_end.add([]);
        }
    });
    // 触发管段
    $elec_segment.element.on('select',function(e,v){
        var id = v || $elec_segment.val();
        if(id){
            // 起点 & 终点
            DyyBase.ajax(DyyBase.url_segment_pos(), {pipeSegmentId:id}, function(dataset){
                var begin = DyyBase.getPos(dataset,'begin');
                var end = DyyBase.getPos(dataset,'end');
                $elec_begin.asset(begin);
                $elec_end.asset(end);
            });
        }else{
            $elec_begin.add([]);
            $elec_end.add([]);
        }
    });
    /***排流装置表单end***/

    /***筛选数据start***/
    var filter = {
        //阴保电源
        getPowerFilter: function(data){
            var filter = {};
            // 分页参数
            if (data) {
                if (data.start == 0) {
                    filter['jsonBean.pageNum'] = 1;
                } else {
                    filter['jsonBean.pageNum'] = data.start / 10 + 1;
                }
                filter['jsonBean.pageCount'] = data.length;
            }
            //查询参数
            filter.pipeLineId = function(){
                var v = $power_pipeline.val();
                if(v){
                    return v;
                }
                return '';
            }();
            filter.beginMileage = function(){
                var v = $power_begin.val('mile');
                if(v){
                    return v;
                }else if(v == 0){
                    return v;
                }
                return '';
            }();
            filter.endMileage = function(){
                var v = $power_end.val('mile');
                if(v){
                    return v;
                }else if(v == 0){
                    return v;
                }
                return '';
            }();
            filter.pipeValveroomId = function (){
                var v = $power_station.val();
                if(v){
                    return v;
                }
                return '';
            }();
            filter.cppowerType = function(){
                var v = $power_type.val();
                if(v){
                    return v;
                }
                return '';
            }();
            filter.protectionObject = function(){
                var v = $power_protect.val();
                if(v){
                    return v;
                }
                return '';
            }();
            return filter;
        },
        //长效参比
        getLongFilter: function(data){
            var filter = {};
            // 分页参数
            if (data) {
                if (data.start == 0) {
                    filter['jsonBean.pageNum'] = 1;
                } else {
                    filter['jsonBean.pageNum'] = data.start / 10 + 1;
                }
                filter['jsonBean.pageCount'] = data.length;
            }
            //查询参数
            filter.pipeValveroomId = function(){
                var v = $long_station.val();
                if(v){
                    return v;
                }
                return '';
            }();
            filter.referenceTypes = function(){
                var v = $long_type.val();
                if(v){
                    return v;
                }
                return v;
            }();
            filter.pipeLineId = function(){
                var v = $long_pipeline.val();
                if(v){
                    return v;
                }
                return '';
            }();
            filter.beginMileage = function(){
                var v = $long_begin.val('mile');
                if (v) {
                    return v;
                }else if(v == 0){
                    return v;
                }
                return '';
            }();
            filter.endMileage = function(){
                var v = $long_end.val('mile');
                if(v){
                    return v;
                }else if(v == 0){
                    return v;
                }
                return '';
            }();
            return filter;
        },
        //阳极地床
        getBedFilter: function(data){
            var filter = {};
            // 分页参数
            if (data) {
                if (data.start == 0) {
                    filter['jsonBean.pageNum'] = 1;
                } else {
                    filter['jsonBean.pageNum'] = data.start / 10 + 1;
                }
                filter['jsonBean.pageCount'] = data.length;
            }
            //查询参数
            filter.pipeLineId = function(){
                var v = $bed_pipeline.val();
                if(v){
                    return v;
                }
                return '';
            }();
            filter.beginMileage = function(){
                var v = $bed_begin.val('mile');
                if(v){
                    return v;
                }else if(v == 0){
                    return v;
                }
                return '';
            }();
            filter.endMileage = function(){
                var v = $bed_end.val('mile');
                if(v){
                    return v;
                }else if(v == 0){
                    return v;
                }
                return '';
            }();
            filter.pipeValveroomId = function(){
                var v = $bed_station.val();
                if(v){
                    return v;
                }
                return '';
            }();
            filter.materialType = function(){
                var v = $bed_type.val();
                if(v){
                    return v;
                }
                return '';
            }();
            filter.protectionObject = function(){
                var v = $bed_protect.val();
                if(v){
                    return v;
                }
                return '';
            }();
            return filter;
        },
        //绝缘装置
        getInsuFilter: function(data){
            var filter = {};
            // 分页参数
            if (data) {
                if (data.start == 0) {
                    filter['jsonBean.pageNum'] = 1;
                } else {
                    filter['jsonBean.pageNum'] = data.start / 10 + 1;
                }
                filter['jsonBean.pageCount'] = data.length;
            }
            //查询参数
            filter.pipeValveroomId = function(){
                var v = $insu_station.val();
                if(v){
                    return v;
                }
                return '';
            }();
            filter.pipeLineId = function(){
                var v = $insu_pipeline.val();
                if(v){
                    return v;
                }
                return '';
            }();
            filter.beginMileage = function(){
                var v = $insu_begin.val('mile');
                if(v){
                    return v;
                }else if(v == 0){
                    return v;
                }
                return '';
            }();
            filter.endMileage = function(){
                var v = $insu_end.val('mile');
                if(v){
                    return v;
                }else if(v == 0){
                    return v;
                }
                return '';
            }();
            return filter;
        },
        //防浪涌保护器
        getAvoidFilter: function(data){
            var filter = {};
            // 分页参数
            if (data) {
                if (data.start == 0) {
                    filter['jsonBean.pageNum'] = 1;
                } else {
                    filter['jsonBean.pageNum'] = data.start / 10 + 1;
                }
                filter['jsonBean.pageCount'] = data.length;
            }
            //查询参数
            filter.pipeValveroomId = function(){
                var v = $avoid_station.val();
                if(v){
                    return v;
                }
                return '';
            }();
            filter.pipeLineId = function(){
                var v = $avoid_pipeline.val();
                if(v){
                    return v;
                }
                return '';
            }();
            filter.beginMileage = function(){
                var v = $avoid_begin.val('mile');
                if(v){
                    return v;
                }else if(v == 0){
                    return v;
                }
                return '';
            }();
            filter.endMileage = function(){
                var v = $avoid_end.val('mile');
                if(v){
                    return v;
                }else if(v == 0){
                    return v;
                }
                return '';
            }();
            return filter;
        },
        //跨接线
        getLineFilter: function(data){
            var filter = {};
            // 分页参数
            if (data) {
                if (data.start == 0) {
                    filter['jsonBean.pageNum'] = 1;
                } else {
                    filter['jsonBean.pageNum'] = data.start / 10 + 1;
                }
                filter['jsonBean.pageCount'] = data.length;
            }
            //查询参数
            filter.pipeValveroomId = function(){
                var v = $line_station.val();
                if(v){
                    return v;
                }
                return '';
            }();
            filter.pipeLineId = function(){
                var v = $line_pipeline.val();
                if(v){
                    return v;
                }
                return '';
            }();
            filter.beginMileage = function(){
                var v = $line_begin.val('mile');
                if(v){
                    return v;
                }else if(v == 0){
                    return v;
                }
                return '';
            }();
            filter.endMileage = function(){
                var v = $line_end.val('mile');
                if(v){
                    return v;
                }else if(v == 0){
                    return v;
                }
                return '';
            }();
            return filter;
        },
        //测试阴保桩
        getPileFilter: function(data){
            var filter = {};
            // 分页参数
            if (data) {
                if (data.start == 0) {
                    filter['jsonBean.pageNum'] = 1;
                } else {
                    filter['jsonBean.pageNum'] = data.start / 10 + 1;
                }
                filter['jsonBean.pageCount'] = data.length;
            }
            //查询参数
            filter.purpose = function(){
                var v = $pile_function.val();
                if(v){
                    return v;
                }
                return '';
            }();
            filter.pipeLineId = function(){
                var v = $pile_pipeline.val();
                if(v){
                    return v;
                }
                return '';
            }();
            filter.beginMileage = function(){
                var v = $pile_begin.val('mile');
                if(v){
                    return v;
                }else if(v == 0){
                    return v;
                }
                return '';
            }();
            filter.endMileage = function(){
                var v = $pile_end.val('mile');
                if(v){
                    return v;
                }else if(v == 0){
                    return v;
                }
                return '';
            }();
            return filter;
        },
        //牺牲阳极
        getSacriFilter: function(data){
            var filter = {};
            // 分页参数
            if (data) {
                if (data.start == 0) {
                    filter['jsonBean.pageNum'] = 1;
                } else {
                    filter['jsonBean.pageNum'] = data.start / 10 + 1;
                }
                filter['jsonBean.pageCount'] = data.length;
            }
            //查询参数
            filter.protectionObject = function(){
                var v = $sacri_protect.val();
                if(v){
                    return v;
                }
                return '';
            }();
            filter.pipeLineId = function(){
                var v = $sacri_pipeline.val();
                if(v){
                    return v;
                }
                return '';
            }();
            filter.beginMileage = function(){
                var v = $sacri_begin.val('mile');
                if(v){
                    return v;
                }else if(v == 0){
                    return v;
                }
                return '';
            }();
            filter.endMileage = function(){
                var v = $sacri_end.val('mile');
                if(v){
                    return v;
                }else if(v == 0){
                    return v;
                }
                return '';
            }();
            return filter;
        },
        //排流装置
        getElecFilter: function(data){
            var filter = {};
            // 分页参数
            if (data) {
                if (data.start == 0) {
                    filter['jsonBean.pageNum'] = 1;
                } else {
                    filter['jsonBean.pageNum'] = data.start / 10 + 1;
                }
                filter['jsonBean.pageCount'] = data.length;
            }
            //查询参数
            filter.currentdrainage = function(){
                var v = $elec_type.val();
                if(v){
                    return v;
                }
                return '';
            }();
            filter.pipeLineId = function(){
                var v = $elec_pipeline.val();
                if(v){
                    return v;
                }
                return '';
            }();
            filter.beginMileage = function(){
                var v = $elec_begin.val('mile');
                if(v){
                    return v;
                }else if(v == 0){
                    return v;
                }
                return '';
            }();
            filter.endMileage = function(){
                var v = $elec_end.val('mile');
                if(v){
                    return v;
                }else if(v == 0){
                    return v;
                }
                return '';
            }();
            return filter;
        }
    };
    /***筛选数据end***/

    /***九个表格数据加载start***/
    //阴保电源表格数据
    function loadPower(){
        var $power_load = $('#JQ_power_load');
        if($power_load.text() == '0'){
            //表单
            DyyBase.ajax(corrctrlApi.url_power_type(), {}, function(dataset){
                var json = DyyBase.getSelect(dataset);
                $power_type.add(json);
            });
            //表格
            DTPOWER = $power_table.DataTable({
                'language': {
                    'paginate': {
                        'next': '下一页',
                        'previous': '上一页'
                    },
                    'info': '本次检索共 _TOTAL_ 条，每页显示 10 条，共 _PAGES_ 页',
                    'zeroRecords': DyyBase.table_empty(),
                    'infoEmpty': ''
                },
                'autoWidth': false,
                'order': [],
                'serverSide': true,
                'pageLength': 10,
                'ordering': false,
                'processing': false,
                'searching': false,
                'lengthChange': false,
                'ajax': function (data, callback) {
                    var param = filter.getPowerFilter(data);
                    DyyBase.ajax(corrctrlApi.url_device_power(), param, function (dataset) {
                        var returnData = {};
                        returnData.draw = data.draw;
                        returnData.recordsTotal = dataset.result.total;
                        returnData.recordsFiltered = dataset.result.total;
                        returnData.data = DyyBase.clearNull(dataset.result.list);
                        callback(returnData);
                    });
                },
                'drawCallback': function () {
                },
                'columns': [
                    {
                        data: 'customNumber',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'pipeValveroomName',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'cppowerType',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'ratedvoltsOut',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'ratedampsout',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'protectionObject',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'model',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'inserviceDate',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'id',
                        render: function (data,type,row) {
                            if(row.isHavRec == true){
                                return '<i id="' + data + '" class="zy-record-icon" title="整改记录"></i>';
                            }else{
                                return '<i id="' + data + '" class="zy-record-null-icon"></i>';
                            }
                        }
                    }
                ]
            });
            $power_load.text('1');
        }
    }
    //长效参比表格数据
    function loadLong(){
        var long_load = $('#JQ_long_load');
        if(long_load.text() == '0'){
            //表单
            DyyBase.ajax(corrctrlApi.url_long_type(), {}, function(dataset){
                var json = DyyBase.getSelect(dataset);
                $long_type.add(json);
            });
            //表格
            DTLONG = $long_table.DataTable({
                'language': {
                    'paginate': {
                        'next': '下一页',
                        'previous': '上一页'
                    },
                    'info': '本次检索共 _TOTAL_ 条，每页显示 10 条，共 _PAGES_ 页',
                    'zeroRecords': DyyBase.table_empty(),
                    'infoEmpty': ''
                },
                'autoWidth': false,
                'order': [],
                'serverSide': true,
                'pageLength': 10,
                'ordering': false,
                'processing': false,
                'searching': false,
                'lengthChange': false,
                'ajax': function (data, callback) {
                    var param = filter.getLongFilter(data);
                    DyyBase.ajax(corrctrlApi.url_device_long(), param, function (dataset) {
                        var returnData = {};
                        returnData.draw = data.draw;
                        returnData.recordsTotal = dataset.result.total;
                        returnData.recordsFiltered = dataset.result.total;
                        returnData.data = DyyBase.clearNull(dataset.result.list);
                        callback(returnData);
                    });
                },
                'drawCallback': function () {
                },
                'columns': [
                    {
                        data: 'pipeLineName',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'pipeValveroomName',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'testStationNumber',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'customNumber',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'referenceTypes',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'inserviceDate',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'assemblyCompany',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'id',
                        render: function (data,type,row) {
                            if(row.isHavRec == true){
                                return '<i id="' + data + '" class="zy-record-icon" title="整改记录"></i>';
                            }else{
                                return '<i id="' + data + '" class="zy-record-null-icon"></i>';
                            }
                        }
                    }
                ]
            });
            long_load.text('1');
        }
    }
    //阳极地床表格数据
    function loadBed(){
        var bed_load = $('#JQ_bed_load');
        if(bed_load.text() == '0'){
            //表单
            DyyBase.ajax(corrctrlApi.url_bed_type(), {}, function(dataset){
                var json = DyyBase.getSelect(dataset);
                $bed_type.add(json);
            });
            //表格
            DTBED = $bed_table.DataTable({
                'language': {
                    'paginate': {
                        'next': '下一页',
                        'previous': '上一页'
                    },
                    'info': '本次检索共 _TOTAL_ 条，每页显示 10 条，共 _PAGES_ 页',
                    'zeroRecords': DyyBase.table_empty(),
                    'infoEmpty': ''
                },
                'autoWidth': false,
                'order': [],
                'serverSide': true,
                'pageLength': 10,
                'ordering': false,
                'processing': false,
                'searching': false,
                'lengthChange': false,
                'ajax': function (data, callback) {
                    var param = filter.getBedFilter(data);
                    DyyBase.ajax(corrctrlApi.url_device_bed(), param, function (dataset) {
                        var returnData = {};
                        returnData.draw = data.draw;
                        returnData.recordsTotal = dataset.result.total;
                        returnData.recordsFiltered = dataset.result.total;
                        returnData.data = DyyBase.clearNull(dataset.result.list);
                        callback(returnData);
                    });
                },
                'drawCallback': function () {
                },
                'columns': [
                    {
                        data: 'customNumber',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'pipeValveroomName',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'materialType',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'classNumberOfAnodes',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'groundbeDstructure',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'protectionObject',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'groundingResistance',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'buriedsoilResistivity',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'id',
                        render: function (data,type,row) {
                            if(row.isHavRec == true){
                                return '<i id="' + data + '" class="zy-record-icon" title="整改记录"></i>';
                            }else{
                                return '<i id="' + data + '" class="zy-record-null-icon"></i>';
                            }
                        }
                    }
                ]
            });
            bed_load.text('1');
        }
    }
    //绝缘装置表格数据
    function loadInsu(){
        var insu_load = $('#JQ_insu_load');
        if(insu_load.text() == '0'){
            DTINSU = $insu_table.DataTable({
                'language': {
                    'paginate': {
                        'next': '下一页',
                        'previous': '上一页'
                    },
                    'info': '本次检索共 _TOTAL_ 条，每页显示 10 条，共 _PAGES_ 页',
                    'zeroRecords': DyyBase.table_empty(),
                    'infoEmpty': ''
                },
                'autoWidth': false,
                'order': [],
                'serverSide': true,
                'pageLength': 10,
                'ordering': false,
                'processing': false,
                'searching': false,
                'lengthChange': false,
                'ajax': function (data, callback) {
                    var param = filter.getInsuFilter(data);
                    DyyBase.ajax(corrctrlApi.url_device_insu(), param, function (dataset) {
                        var returnData = {};
                        returnData.draw = data.draw;
                        returnData.recordsTotal = dataset.result.total;
                        returnData.recordsFiltered = dataset.result.total;
                        returnData.data = DyyBase.clearNull(dataset.result.list);
                        callback(returnData);
                    });
                },
                'drawCallback': function () {
                },
                'columns': [
                    {
                        data: 'pipeLineName',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'pipeValveroomName',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'testStationNumber',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'insulatedJointType',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'mileage',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'mountingPosition',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'protectionFacilities',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'id',
                        render: function (data,type,row) {
                            if(row.isHavRec == true){
                                return '<i id="' + data + '" class="zy-record-icon" title="整改记录"></i>';
                            }else{
                                return '<i id="' + data + '" class="zy-record-null-icon"></i>';
                            }
                        }
                    }
                ]
            });
            insu_load.text('1');
        }
    }
    //防浪涌保护器表格数据
    function loadAvoid(){
        var avoid_load = $('#JQ_avoid_load');
        if(avoid_load.text() == '0'){
            DTAVOID = $avoid_table.DataTable({
                'language': {
                    'paginate': {
                        'next': '下一页',
                        'previous': '上一页'
                    },
                    'info': '本次检索共 _TOTAL_ 条，每页显示 10 条，共 _PAGES_ 页',
                    'zeroRecords': DyyBase.table_empty(),
                    'infoEmpty': ''
                },
                'autoWidth': false,
                'order': [],
                'serverSide': true,
                'pageLength': 10,
                'ordering': false,
                'processing': false,
                'searching': false,
                'lengthChange': false,
                'ajax': function (data, callback) {
                    var param = filter.getAvoidFilter(data);
                    DyyBase.ajax(corrctrlApi.url_device_avoid(), param, function (dataset) {
                        var returnData = {};
                        returnData.draw = data.draw;
                        returnData.recordsTotal = dataset.result.total;
                        returnData.recordsFiltered = dataset.result.total;
                        returnData.data = DyyBase.clearNull(dataset.result.list);
                        callback(returnData);
                    });
                },
                'drawCallback': function () {
                },
                'columns': [
                    {
                        data: 'pipeLineName',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'pipeValveroomName',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'teststationnumber',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'potectorType',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'mileage',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'mountingType',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'specifications',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'id',
                        render: function (data,type,row) {
                            if(row.isHavRec == true){
                                return '<i id="' + data + '" class="zy-record-icon" title="整改记录"></i>';
                            }else{
                                return '<i id="' + data + '" class="zy-record-null-icon"></i>';
                            }
                        }
                    }
                ]
            });
            avoid_load.text('1');
        }
    }
    //跨接线表格数据
    function loadLine(){
        var line_load = $('#JQ_line_load');
        if(line_load.text() == '0'){
            DTLINE = $line_table.DataTable({
                'language': {
                    'paginate': {
                        'next': '下一页',
                        'previous': '上一页'
                    },
                    'info': '本次检索共 _TOTAL_ 条，每页显示 10 条，共 _PAGES_ 页',
                    'zeroRecords': DyyBase.table_empty(),
                    'infoEmpty': ''
                },
                'autoWidth': false,
                'order': [],
                'serverSide': true,
                'pageLength': 10,
                'ordering': false,
                'processing': false,
                'searching': false,
                'lengthChange': false,
                'ajax': function (data, callback) {
                    var param = filter.getLineFilter(data);
                    DyyBase.ajax(corrctrlApi.url_device_line(), param, function (dataset) {
                        var returnData = {};
                        returnData.draw = data.draw;
                        returnData.recordsTotal = dataset.result.total;
                        returnData.recordsFiltered = dataset.result.total;
                        returnData.data = DyyBase.clearNull(dataset.result.list);
                        callback(returnData);
                    });
                },
                'drawCallback': function () {
                },
                'columns': [
                    {
                        data: 'pipeLineName',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'pipeValveroomName',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'teststationnumber',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'jumperType',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'beginMileage',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'endMileage',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'id',
                        render: function (data,type,row) {
                            if(row.isHavRec == true){
                                return '<i id="' + data + '" class="zy-record-icon" title="整改记录"></i>';
                            }else{
                                return '<i id="' + data + '" class="zy-record-null-icon"></i>';
                            }
                        }
                    }
                ]
            });
            line_load.text('1');
        }
    }
    //阴保测试桩表格数据
    function loadPile(){
        var pile_load = $('#JQ_pile_load');
        if(pile_load.text() == '0'){
            //表单
            DyyBase.ajax(corrctrlApi.url_pile_function(), {}, function(dataset){
                var json = DyyBase.getSelect(dataset);
                $pile_function.add(json);
            });
            //表格
            DTPILE = $cpile_table.DataTable({
                'language': {
                    'paginate': {
                        'next': '下一页',
                        'previous': '上一页'
                    },
                    'info': '本次检索共 _TOTAL_ 条，每页显示 10 条，共 _PAGES_ 页',
                    'zeroRecords': DyyBase.table_empty(),
                    'infoEmpty': ''
                },
                'autoWidth': false,
                'order': [],
                'serverSide': true,
                'pageLength': 10,
                'ordering': false,
                'processing': false,
                'searching': false,
                'lengthChange': false,
                'ajax': function (data, callback) {
                    var param = filter.getPileFilter(data);
                    DyyBase.ajax(corrctrlApi.url_device_pile(), param, function (dataset) {
                        var returnData = {};
                        returnData.draw = data.draw;
                        returnData.recordsTotal = dataset.result.total;
                        returnData.recordsFiltered = dataset.result.total;
                        returnData.data = DyyBase.clearNull(dataset.result.list);
                        callback(returnData);
                    });
                },
                'drawCallback': function () {
                },
                'columns': [
                    {
                        data: 'pipeLineName',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'customNumber',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'mileage',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'material',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'purpose',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'solderJointsCorrosion',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'id',
                        render: function (data,type,row) {
                            if(row.isHavRec == true){
                                return '<i id="' + data + '" class="zy-record-icon" title="整改记录"></i>';
                            }else{
                                return '<i id="' + data + '" class="zy-record-null-icon"></i>';
                            }
                        }
                    }
                ]
            });
            pile_load.text('1');
        }
    }
    //牺牲阳极表格数据
    function loadSacri(){
        var sacri_load = $('#JQ_sacri_load');
        if(sacri_load.text() == '0'){
            DyyBase.ajax(corrctrlApi.url_sacri_protect(), {}, function(dataset){
                var json = DyyBase.getSelect(dataset);
                $sacri_protect.add(json);
            });
            DyyBase.ajax(corrctrlApi.url_elec_type(), {}, function(dataset){
                var json = DyyBase.getSelect(dataset);
                $elec_type.add(json);
            });
            DTSACRI = $sacri_table.DataTable({
                'language': {
                    'paginate': {
                        'next': '下一页',
                        'previous': '上一页'
                    },
                    'info': '本次检索共 _TOTAL_ 条，每页显示 10 条，共 _PAGES_ 页',
                    'zeroRecords': DyyBase.table_empty(),
                    'infoEmpty': ''
                },
                'autoWidth': false,
                'order': [],
                'serverSide': true,
                'pageLength': 10,
                'ordering': false,
                'processing': false,
                'searching': false,
                'lengthChange': false,
                'ajax': function (data, callback) {
                    var param = filter.getSacriFilter(data);
                    DyyBase.ajax(corrctrlApi.url_device_sacri(), param, function (dataset) {
                        var returnData = {};
                        returnData.draw = data.draw;
                        returnData.recordsTotal = dataset.result.total;
                        returnData.recordsFiltered = dataset.result.total;
                        returnData.data = DyyBase.clearNull(dataset.result.list);
                        callback(returnData);
                    });
                },
                'drawCallback': function () {
                },
                'columns': [
                    {
                        data: 'pipeLineName',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'teststationnumber',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'material',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'sacrificialAnodeType',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'anodeCount',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'installation',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'protectionObject',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'coatingMaterial',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'id',
                        render: function (data,type,row) {
                            if(row.isHavRec == true){
                                return '<i id="' + data + '" class="zy-record-icon" title="整改记录"></i>';
                            }else{
                                return '<i id="' + data + '" class="zy-record-null-icon"></i>';
                            }
                        }
                    }
                ]
            });
            sacri_load.text('1');
        }
    }
    //排流装置表格数据
    function loadElec(){
        var elec_load = $('#JQ_elec_load');
        if(elec_load.text() == '0'){
            DTELEC = $elec_table.DataTable({
                'language': {
                    'paginate': {
                        'next': '下一页',
                        'previous': '上一页'
                    },
                    'info': '本次检索共 _TOTAL_ 条，每页显示 10 条，共 _PAGES_ 页',
                    'zeroRecords': DyyBase.table_empty(),
                    'infoEmpty': ''
                },
                'autoWidth': false,
                'order': [],
                'serverSide': true,
                'pageLength': 10,
                'ordering': false,
                'processing': false,
                'searching': false,
                'lengthChange': false,
                'ajax': function (data, callback) {
                    var param = filter.getElecFilter(data);
                    DyyBase.ajax(corrctrlApi.url_device_elec(), param, function (dataset) {
                        var returnData = {};
                        returnData.draw = data.draw;
                        returnData.recordsTotal = dataset.result.total;
                        returnData.recordsFiltered = dataset.result.total;
                        returnData.data = DyyBase.clearNull(dataset.result.list);
                        callback(returnData);
                    });
                },
                'drawCallback': function () {
                },
                'columns': [
                    {
                        data: 'customNumber',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'pipeLineName',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'pipeValveroomName',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'currentdrainage',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'interferenceType',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'drainageMethod',
                        render: function (data) {
                            return '<span title="' + data + '">' + data + '</span>';
                        }
                    },
                    {
                        data: 'id',
                        render: function (data,type,row) {
                            if(row.isHavRec == true){
                                return '<i id="' + data + '" class="zy-record-icon" title="整改记录"></i>';
                            }else{
                                return '<i id="' + data + '" class="zy-record-null-icon"></i>';
                            }
                        }
                    }
                ]
            });
            elec_load.text('1');
        }
    }
    /***九个表格数据加载end***/

    /*** html5的本地储存方式，作用：在不关闭页面的情况下，刷新能实现刷线当前tab页，不会跳转到初始化页面 ***/
    if(window.sessionStorage.Type == 'POWER'){
        $nav.eq(0).addClass('xyf-nav-select');
        $nav_content.eq(0).show();
        loadPower();
    }else if(window.sessionStorage.Type == 'LONG'){
        $nav.eq(1).addClass('xyf-nav-select');
        $nav_content.eq(1).show();
        loadLong();
    }else if(window.sessionStorage.Type == 'BED'){
        $nav.eq(2).addClass('xyf-nav-select');
        $nav_content.eq(2).show();
        loadBed();
    }else if(window.sessionStorage.Type == 'INSU'){
        $nav.eq(3).addClass('xyf-nav-select');
        $nav_content.eq(3).show();
        loadInsu();
    }else if(window.sessionStorage.Type == 'AVOID'){
        $nav.eq(4).addClass('xyf-nav-select');
        $nav_content.eq(4).show();
        loadAvoid();
    }else if(window.sessionStorage.Type == 'LINE'){
        $nav.eq(5).addClass('xyf-nav-select');
        $nav_content.eq(5).show();
        loadLine();
    }else if(window.sessionStorage.Type == 'PILE'){
        $nav.eq(6).addClass('xyf-nav-select');
        $nav_content.eq(6).show();
        loadPile();
    }else if(window.sessionStorage.Type == 'SACRI'){
        $nav.eq(7).addClass('xyf-nav-select');
        $nav_content.eq(7).show();
        loadSacri();
    }else if(window.sessionStorage.Type == 'ELEC'){
        $nav.eq(8).addClass('xyf-nav-select');
        $nav_content.eq(8).show();
        loadElec();
    }else{
        $nav.eq(0).addClass('xyf-nav-select');
        $nav_content.eq(0).show();
        loadPower();
    }
    /*** end ***/

    /*** 表格的查询功能start ***/
        //阴保电源查询
    $('#JQ_power_search').click(function () {
        if(DTPOWER){
            DTPOWER.draw();
        }
    });
    //长效参比查询
    $('#JQ_long_search').click(function () {
        if(DTLONG){
            DTLONG.draw();
        }
    });
    //阳极地床查询
    $('#JQ_bed_search').click(function () {
        if(DTBED){
            DTBED.draw();
        }
    });
    //绝缘装置查询
    $('#JQ_insu_search').click(function () {
        if(DTINSU){
            DTINSU.draw();
        }
    });
    //防浪涌保护器查询
    $('#JQ_avoid_search').click(function () {
        if(DTAVOID){
            DTAVOID.draw();
        }
    });
    //跨接线查询
    $('#JQ_line_search').click(function () {
        if(DTLINE){
            DTLINE.draw();
        }
    });
    //阴保测试桩查询
    $('#JQ_pile_search').click(function () {
        if(DTPILE){
            DTPILE.draw();
        }
    });
    //牺牲阳极查询
    $('#JQ_sacri_search').click(function () {
        if(DTSACRI){
            DTSACRI.draw();
        }
    });
    //排流装置查询
    $('#JQ_elec_search').click(function () {
        if(DTELEC){
            DTELEC.draw();
        }
    });
    /*** 表格的查询功能end ***/

    /*** 点击查看记录详情页面start ***/
    //阴保电源整改记录
    $power_table.delegate('i.zy-record-icon','click',function(event){
        // 当前对象
        var $this_i = $(this);
        var Id = $this_i.attr('id');
        var url = corrctrlApi.url_rectify_detail() + '?eqptId=' + Id +'&eqptType=CPPOWER';
        window.location.href = url;
        event.stopPropagation();
    });
    //长效参比整改记录
    $long_table.delegate('i.zy-record-icon','click',function(event){
        // 当前对象
        var $this_i = $(this);
        var Id = $this_i.attr('id');
        var url = corrctrlApi.url_rectify_detail() + '?eqptId=' + Id +'&eqptType=REFERENCE';
        window.location.href = url;
        event.stopPropagation();
    });
    //阳极地床整改记录
    $bed_table.delegate('i.zy-record-icon','click',function(event){
        // 当前对象
        var $this_i = $(this);
        var Id = $this_i.attr('id');
        var url = corrctrlApi.url_rectify_detail() + '?eqptId=' + Id +'&eqptType=ANODESBED';
        window.location.href = url;
        event.stopPropagation();
    });
    //绝缘装置整改记录
    $insu_table.delegate('i.zy-record-icon','click',function(event){
        // 当前对象
        var $this_i = $(this);
        var Id = $this_i.attr('id');
        var url = corrctrlApi.url_rectify_detail() + '?eqptId=' + Id +'&eqptType=INSULATEDJOINT';
        window.location.href = url;
        event.stopPropagation();
    });
    //防浪涌保护器整改记录
    $avoid_table.delegate('i.zy-record-icon','click',function(event){
        // 当前对象
        var $this_i = $(this);
        var Id = $this_i.attr('id');
        var url = corrctrlApi.url_rectify_detail() + '?eqptId=' + Id +'&eqptType=ANTISURGE';
        window.location.href = url;
        event.stopPropagation();
    });
    //跨接线整改记录
    $line_table.delegate('i.zy-record-icon','click',function(event){
        // 当前对象
        var $this_i = $(this);
        var Id = $this_i.attr('id');
        var url = corrctrlApi.url_rectify_detail() + '?eqptId=' + Id +'&eqptType=CPJUMPER';
        window.location.href = url;
        event.stopPropagation();
    });
    //阴保测试桩整改记录
    $cpile_table.delegate('i.zy-record-icon','click',function(event){
        // 当前对象
        var $this_i = $(this);
        var Id = $this_i.attr('id');
        var url = corrctrlApi.url_rectify_detail() + '?eqptId=' + Id +'&eqptType=CPTESTSTATION';
        window.location.href = url;
        event.stopPropagation();
    });
    //牺牲阳极整改记录
    $sacri_table.delegate('i.zy-record-icon','click',function(event){
        // 当前对象
        var $this_i = $(this);
        var Id = $this_i.attr('id');
        var url = corrctrlApi.url_rectify_detail() + '?eqptId=' + Id +'&eqptType=SAALANODE';
        window.location.href = url;
        event.stopPropagation();
    });
    //排流装置整改记录
    $elec_table.delegate('i.zy-record-icon','click',function(event){
        // 当前对象
        var $this_i = $(this);
        var Id = $this_i.attr('id');
        var url = corrctrlApi.url_rectify_detail() + '?eqptId=' + Id +'&eqptType=CURRENTDRAINAGE';
        window.location.href = url;
        event.stopPropagation();
    });
    /*** 点击查看记录详情页面 end ***/


    /*** tab切换 ***/
    $nav.click(function(){
        var $this = $(this);
        var index = $this.index();
        $nav.eq(index).addClass('xyf-nav-select').siblings().removeClass('xyf-nav-select');
        $nav_content.hide().eq(index).show();
        if(index == 0){
            loadPower();
            window.sessionStorage.Type = 'POWER';
        }else if(index == 1){
            loadLong();
            window.sessionStorage.Type = 'LONG';
        }else if(index == 2){
            loadBed();
            window.sessionStorage.Type = 'BED';
        }else if(index == 3){
            loadInsu();
            window.sessionStorage.Type = 'INSU';
        }else if(index == 4){
            loadAvoid();
            window.sessionStorage.Type = 'AVOID';
        }else if(index == 5){
            loadLine();
            window.sessionStorage.Type = 'LINE';
        }else if(index == 6){
            loadPile();
            window.sessionStorage.Type = 'PILE';
        }else if(index == 7){
            loadSacri();
            window.sessionStorage.Type = 'SACRI';
        }else if(index == 8){
            loadElec();
            window.sessionStorage.Type = 'ELEC';
        }
    });
})($,window,document,undefined);